#ifndef _Util_H__

#include "yaml-cpp/yaml.h"
#include "OCMain/Log.h"
#include "OCMain/FileUtil.h"
#include "OCMain/Environment.h"
#include "OCGrib/GribWrapper.h"

using namespace OCPP;

template <typename T>
T getYaml(YAML::Node node, std::vector<String> pathVec) {

	std::vector<YAML::Node> nodePath;
	nodePath.push_back(node);

	for (auto i = 0; i < pathVec.size(); i++)
	{
		String name = pathVec[i];
		YAML::Node node1 = nodePath.back()[name];
		if (!node1.IsDefined()) {
			String msg = "yaml bad path [";
			for (auto j = 0; j != i; j++)
			{
				msg += pathVec[j] + ":";
			}
			msg += name + "]";
			throw YAML::Exception(node1.Mark(), msg.c_str());
		}
		nodePath.push_back(node1);
	}

	return nodePath.back().as<T>();
}

class Util
{
public:
	const static String DbName;
	static void initDB();
	static void loadConfig();
	static StringVector findM4File(String path);
	static StringVector findM4JsonFile(String path);

	static int ExpiredTime;
	static String DataPath;
	static String CachePath;
	static String CachePath_ICE_COVER;
	static bool KeepHistory;
};

#endif // !_Util_H__
